﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace PatientManagement.Common.Utils
{
    public static class Utilities
    {
        public static void Map<T>(this IEnumerable<T> source, Action<T> func)
        {
            foreach (T i in source)
            {
                func(i);
            }
        }

        public static void Map<T>(this T source, Action<T> func)
        {
            func(source);
        }

        /// <summary>
        /// Returns id which formating: {day}{month}{year}-{random}
        /// </summary>
        /// <returns></returns>
        public static string GenerateIdNumber()
        {
            string id = string.Empty;
            string gui = Guid.NewGuid()
                .ToString()
                .Split('-')[0]
                .ToUpper();
            return string.Format("{0}{1}{2}-{3}", DateTime.Now.Day, DateTime.Now.Month, DateTime.Now.Year, gui);
        }
    }
}
